RAIS  3.2
C:/Projekte/RAIS/common/FunctionRoleAttribute.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 using System.Data;
00032 
00033 namespace RAIS.Common.UserManagement
00034 {
00038     public class FunctionRoleAttribute : DBObject
00039     {
00040                 #region Fields
00041 //              FunctionRole functionRole;                      ///<FunctionRole object
00042                 FunctionRole.Category category;             
00043                 FunctionRole.Subcategory subcategory;   
00044                 Mask mask;                                                      
00045         bool accessView = false;                
00046         bool accessAdd = false;                 
00047         bool accessEdit = false;                
00048         bool accessDelete = false;              
00049         #endregion
00050                 #region Properties
00051 
00054         //public FunctionRole FunctionRole
00055         //{
00056         //    get { return this.FunctionRole; }
00057         //    set { this.FunctionRole = value; }
00058         //}
00062                 public FunctionRole.Category Category
00063                 {
00064                         get { return this.category; }
00065                         set { this.category = value; }
00066                 }
00070                 public FunctionRole.Subcategory Subcategory
00071                 {
00072                         get { return this.subcategory; }
00073                         set { this.subcategory = value; }
00074                 }
00078                 public Mask Mask
00079                 {
00080                         get { return this.mask; }
00081                         set { this.mask = value; }
00082                 }
00086         public bool AccessView
00087         {
00088             get { return this.accessView; }
00089             set { this.accessView = value; }
00090         }
00094         public bool AccessAdd
00095         {
00096             get { return this.accessAdd; }
00097             set { this.accessAdd = value; }
00098         }
00102         public bool AccessEdit
00103         {
00104             get { return this.accessEdit; }
00105             set { this.accessEdit = value; }
00106         }
00110         public bool AccessDelete
00111         {
00112             get { return this.accessDelete; }
00113             set { this.accessDelete = value; }
00114         }
00118                 public string CategoryName
00119                 {
00120                         get { return this.category.Name; }
00121                 }
00125                 public string SubcategoryName
00126                 {
00127                         get { return this.subcategory.Name; }
00128                 }
00132                 public string MaskName
00133                 {
00134                         get { return this.mask.Name; }
00135                 }
00139                 public string AddPermission
00140                 {
00141                         get { return (this.accessAdd ? Constants.EXISTING_PERMISSION_CHARACTER : Constants.NOT_EXISTING_PERMISSION_CHARACTER); }
00142                 }
00146                 public string EditPermission
00147                 {
00148                         get { return (this.accessEdit ? Constants.EXISTING_PERMISSION_CHARACTER : Constants.NOT_EXISTING_PERMISSION_CHARACTER); }
00149                 }
00153                 public string DeletePermission
00154                 {
00155                         get { return (this.accessDelete ? Constants.EXISTING_PERMISSION_CHARACTER : Constants.NOT_EXISTING_PERMISSION_CHARACTER); }
00156                 }
00160                 public string ViewPermission
00161                 {
00162                         get { return (this.accessView ? Constants.EXISTING_PERMISSION_CHARACTER : Constants.NOT_EXISTING_PERMISSION_CHARACTER); }
00163                 }
00164                 #endregion
00165         #region Public methods
00166         public bool RestricitonsConflict(FunctionRoleAttribute attribute)
00167         {
00168             if (this.Category.RestricitonsConflict(attribute.Category))
00169                 return true;
00170             else
00171             if (this.Category.Name == attribute.Category.Name &&
00172                 this.Subcategory.RestricitonsConflict(attribute.Subcategory))
00173                 return true;
00174             else
00175             if( this.Category.Name == attribute.Category.Name &&
00176                 this.Subcategory.Name == attribute.Subcategory.Name &&
00177                 this.Mask.RestricitonsConflict(attribute.Mask))
00178                 return true;
00179             else
00180                 return false;
00181         }
00182         #endregion
00183         #region Constructors
00184         public FunctionRoleAttribute()
00185         {}
00186         public FunctionRoleAttribute(/*FunctionRole functionRole,*/ IDataRecord record)
00187                 {
00188 //                      this.functionRole = functionRole;
00189                         this.accessView = (bool)record["View Access"];
00190                         this.accessAdd = (bool)record["Add Access"];
00191                         this.accessEdit = (bool)record["Edit Access"];
00192                         this.accessDelete = (bool)record["Delete Access"];
00193                         this.category = new FunctionRole.Category(record);
00194                         this.subcategory = new FunctionRole.Subcategory(record);
00195                         this.mask = new Mask(record);
00196                 }
00197                 #endregion
00198         #region Overridables
00199         public override string ToString()
00200         {
00201             return this.Category.Name + " " + this.Subcategory.Name + " " + this.Mask.Name;
00202         }
00203         #endregion
00204         }
00205 }